{
   "_id": "_design/TweetAnalytics",
   "_rev": "6-3fd2a6bf6f76d2823392d714abd336a0",
   "language": "javascript",
   "views": {
       "TweetCountByHour": {
           "map": "function(doc) {\n\tvar createDate = new Date(doc.created_at);\n\tvar period = null;\n\tif (createDate.getHours() >= 0 && createDate.getHours() < 12) {\n\t\tperiod = \"AM\";\n\t} else {\n\t\tperiod= \"PM\";\n\t}\n\temit([createDate.getHours()], 1);\n}",
           "reduce": "_count"
       },
       "TweetCountByLanguage": {
           "map": "function(doc) {\n\temit(doc.lang, 1);\n}",
           "reduce": "_count"
       },
       "TweetByUser": {
           "map": "function(doc) {\n\temit([doc.user.id_str, doc.user.name], 1);\n}",
           "reduce": "_count"
       },
       "TweetCoordByUser": {
           "map": "function(doc) {\n\temit([doc.user.id_str], doc.geo);\n}"
       },
       "TweetCountByPlace": {
           "map": "function (doc) {\n    if (doc.lang == \"en\" && doc.source.indexOf(\"foursquare\") != -1) {\n        var str = doc.text;\n        if (str.indexOf(\"I'm at\") === 0) {\n            str = str.substring(\"I'm at\".length);\n        }\n        if (str.indexOf(\"(\") > -1 && str.lastIndexOf(\")\") > -1) {\n            str = str.substring(str.indexOf(\"(\") + 1, str.lastIndexOf(\")\"));\n        }\n        if (str.indexOf(\"w/\") > -1) {\n            str = str.substring(0, str.indexOf(\"w/\"));\n        }\n        if (str.indexOf(\"-\") > -1) {\n            str = str.substring(0, str.indexOf(\"-\"));\n        }\n        if (str.indexOf(\"http\") > -1) {\n            str = str.substring(0, str.indexOf(\"http\"));\n        }\n\n        emit(str.trim(), null);\n    }\n\n}",
           "reduce": "_count"
       },
       "TweetCountBySource": {
           "map": "function(doc) {      \n\temit(doc.source.substring(doc.source.indexOf(\"follow\\\">\")+8,doc.source.indexOf(\"</a>\")),null);\n}",
           "reduce": "_count"
       }
   },
   "lists": {
       "SortUserByCount": "function (head, request) {provides('json', function () {var results = [];var row; while (row = getRow()) {if (row.value > 20) {results.push({count:row.value,userid:row.key[0],user:row.key[1]});}}results.sort(function (a, b) {return b.count - a.count});send(request.query.callback + \"(\" + JSON.stringify(results) + \");\");});}",
       "SortPlaceByCount": "function (head, request) {provides('json', function () {var results = [];var row; while (row = getRow()) {if (row.value >= 20) {results.push({count:row.value,place:row.key});}}results.sort(function (a, b) {return b.count - a.count});send(request.query.callback + \"(\" + JSON.stringify(results) + \");\");});}",
       "SortSourceByCount": "function (head, request) {provides('json', function () {var results = [];var row; while (row = getRow()) {if (row.value > 30) {results.push({count:row.value,source:row.key});}}results.sort(function (a, b) {return b.count - a.count});send(request.query.callback + \"(\" + JSON.stringify(results) + \");\");});}"
   }
}